﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Marmat.Forms;
using Marmat.Forms.Skin;
using System.Drawing.Drawing2D;

namespace 测试项目
{
    /// <summary>
    /// 通知控件
    /// </summary>
    public partial class NotificationForm : NoneBorderForm
    {
        public NotificationForm()
        {
            InitializeComponent();
            this.DragParentForm();
            this.FormBorderStyle = FormBorderStyle.None;
        }


        public enum NotificationTypeEnum
        {
            /// <summary>
            /// 默认
            /// </summary>
            Default = 0,
            /// <summary>
            /// 成功
            /// </summary>
            Success = 1,
            /// <summary>
            /// 警告
            /// </summary>
            Warning = 2,
            /// <summary>
            /// 提示
            /// </summary>
            Prompt = 3,
            /// <summary>
            /// 警告
            /// </summary>
            Error = 4

        }

        private void NotificationForm_Paint(object sender, PaintEventArgs e)
        {
            e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
            e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
            var rec = new Rectangle(0, 0, this.Width, this.Height);
            var path = rec.GetRoundPath(15);
            e.Graphics.FillPath(Brushes.AliceBlue, path);
            this.Region = new Region(path);
        }

        #region 圆角 
        public void SetWindowRegion()
        {
            System.Drawing.Drawing2D.GraphicsPath FormPath;
            FormPath = new System.Drawing.Drawing2D.GraphicsPath();
            Rectangle rect = new Rectangle(0, 0, this.Width, this.Height);
            FormPath = GetRoundedRectPath(rect, 60);
            this.Region = new Region(FormPath);



        }
        private GraphicsPath GetRoundedRectPath(Rectangle rect, int radius)
        {
            int diameter = radius;
            Rectangle arcRect = new Rectangle(rect.Location, new Size(diameter, diameter));
            GraphicsPath path = new GraphicsPath();

            // 左上角
            path.AddArc(arcRect, 180, 90);

            // 右上角
            arcRect.X = rect.Right - diameter;
            path.AddArc(arcRect, 270, 90);

            // 右下角
            arcRect.Y = rect.Bottom - diameter;
            path.AddArc(arcRect, 0, 90);

            // 左下角
            arcRect.X = rect.Left;
            path.AddArc(arcRect, 90, 90);
            path.CloseFigure();//闭合曲线
            return path;
        }
        #endregion

        private void NotificationForm_Resize(object sender, EventArgs e)
        {

        }
    }
}
